EBSILON®Professional Online Documentation
EbsScript / EbsScript Interface Units / InterfaceUnit Python
In This Topic
    InterfaceUnit Python
    In This Topic

     

    The interface unit “@Python” allows executing Python code directly from the EbsScript. Both code directly and Python files (*.py) can be executed. For using the interface

    1. Python must be installed (Version 2.7 or 3.0 or newer). Python for Windows can be downloaded from https://www.python.org/downloads/windows/.
    2. the Python extension "Python for Windows Extensions" must be installed (see e.g. http://sourceforge.net/projects/pywin32/ ).
    3. the COM class "EbsScriptPython.Interpreter” must be registered: to do so please execute the Python script “<Ebsilon-Install-Path>/Data/Python/ebsscript_python_interpreter.py” with Python.

    During the execution of an EbsScript, the global dictionary of Python is retained, i.e. several calls to Python executed in a row can e.g. create Python variables and subsequently
    read them out.

    CAUTION: After terminating an EbsScript, the global Python dictionary is deleted. Accessing variables from a previous EbsScript run is thus no longer possible via the
    dictionary (this can e.g. be achieved by means of “Python pickling”) The following functions/procedures are contained in>“@Python”.

    These function/procedures are included in „@Python

    function pyEvaluate(expression:string):variant; internal;

    evaluates “expression” and returns the result.

     

    procedure pyExecute(expression:string); internal;

    executes the code in “expression”.

     

    procedure pyExecuteFile(file:string); internal;

    executes the code contained in “file”.

     

    function pyGetVariable(name:String):variant; internal;

    returns the value of the global variable “name” (i.e. element of the global dictionary).

     

    procedure pySetVariable(name:String; const value:variant); internal;

    sets the values of the global variable “name”.

     

    function pyLoadInterpreter():boolean; internal;

    explicitly load python-interpreter; result is true if interpreter could be loaded (or was already loaded) note: explicitly loading the python-interpreter is not necessary.

     

    function pyUnloadInterpreter():boolean; internal;

    unloads the python-interpreter; result is true if interpreter could be unloaded successfully (or was not loaded)

     

    function pyIsInterpreterLoaded():boolean; internal;

    test, if the python-interpreter is loaded; result is true if interpreter is loaded

     

    procedure pySetFullyQualifiedLogfileName(path:string); internal;

    set the fully qualified path of the log-file

     

    function pyGetFullyQualifiedLogfileName():string; internal;

    get the fully qualified path of the log-file

     

    procedure pyEnableLogging(enable:boolean = true); internal;

    enable/disable logging

     

    function pyIsLoggingEnabled():boolean; internal;

    returns true if logging is enabled

     

     

    The interface unit “@Python” allows executing Python code directly from the EbsScript. Both code directly and Python files (*.py) can be executed. For using the interface

    1. Python must be installed (Version 2.7 or 3.0 or newer). Python for Windows can be downloaded from https://www.python.org/downloads/windows/.
    2. the Python extension "Python for Windows Extensions" must be installed (see e.g. http://sourceforge.net/projects/pywin32/ ).
    3. the COM class "EbsScriptPython.Interpreter” must be registered: to do so please execute the Python script “<Ebsilon-Install-Path>/Data/Python/ebsscript_python_interpreter.py” with Python.

    During the execution of an EbsScript, the global dictionary of Python is retained, i.e. several calls to Python executed in a row can e.g. create Python variables and subsequently
    read them out.

    CAUTION: After terminating an EbsScript, the global Python dictionary is deleted. Accessing variables from a previous EbsScript run is thus no longer possible via the
    dictionary (this can e.g. be achieved by means of “Python pickling”) The following functions/procedures are contained in>“@Python”.